<!DOCTYPE html>
<html>
<head>
<!--
  Copyright (c) 2021 Jean-Marc VIGLINO, 
  released under CeCILL-B (french BSD like) licence: http://www.cecill.info/
-->
  <title>ol-ext: ProgressBar</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

  <meta name="description" content="Add a progress bar to your maps." />
  <meta name="keywords" content="openlayers,control,progress,bar,percent" />

  <!-- jQuery -->
  <script type="text/javascript" src="https://code.jquery.com/jquery-1.11.0.min.js"></script>

  <!-- FontAwesome -->
	<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

  <!-- Openlayers -->
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/ol@latest/ol.css" />
  <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ol@latest/dist/ol.js"></script>
  <script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList,URL,Object.assign"></script>
  
  <!-- ol-ext -->
  <link rel="stylesheet" href="../../dist/ol-ext.css" />
  <script type="text/javascript" src="../../dist/ol-ext.js"></script>
  <!-- Pointer events polyfill for old browsers, see https://caniuse.com/#feat=pointer -->
  <script src="https://unpkg.com/elm-pep"></script>

  <link rel="stylesheet" href="../style.css" />
  <style>
    #map {
      width: 100%;
      height: 600px;
    }
    input[type="range"] {
      vertical-align: middle;
      width: 20em;
    }
  </style>
</head>
<body >
  <a href="https://github.com/Viglino/ol-ext" class="icss-github-corner"><i></i></a>

  <a href="../../index.html">
    <h1>ol-ext: ProgressBar</h1>
  </a>
  <div class="info">
    <b>ol/control/ProgressBar</b> add a progress bar to a map.
    <br/>
    Use the <i>layer</i> option listen to tileload event and show the layer loading progress.
    <br/>
    You can use <i>setPercent</i> to set the progress programmatically.
  </div>

  <!-- DIV pour la carte -->
  <div id="map"></div>

  <div class="options">
    set percent: <input type="range" min="0" max="1" step=".1" value="0" onchange="progress.setPercent(this.value);"/>
  </div>
  
  <script type="text/javascript">
  // Layers
  var layers = [
  new ol.layer.Tile({
      title:'terrain',
      source: new ol.source.StadiaMaps({ layer: 'stamen_terrain_background' })
    }),
    new ol.layer.Tile({
      title:'line',
      source: new ol.source.StadiaMaps({ layer: 'stamen_terrain_lines' })
    }),
    new ol.layer.Tile({
      title: 'label',
      source: new ol.source.StadiaMaps({ layer: 'stamen_terrain_labels' })
    })
  ];

  // The map
  var map = new ol.Map ({
    target: 'map',
    view: new ol.View ({
      zoom: 5,
      center: [166326, 5992663]
    }),
    layers: layers
  });

  // ProgressBar
  var progress = new ol.control.ProgressBar({
    // target: $('.options').get(0)
    label: 'Loading...',
    layers: layers
  });
  map.addControl(progress);

  </script>
</body>
</html>